package com.efast.cafe.framework.util;

import java.util.Locale;

import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.context.i18n.LocaleContextHolder;

public class LanguageUtil {

	public static String getValueByJsonLocale(String json){
		try {
			JSONObject jo = new JSONObject(json);
			Locale l = LocaleContextHolder.getLocale();
			return jo.getString(l.toLanguageTag().replaceAll("-", "_"));
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return null;
	}
}
